package com.mail.server.controller;


import com.mail.model.db.PmsSkuStock;
import com.mail.model.vo.PageResult;
import com.mail.server.common.R;
import com.mail.server.service.PmsSkuStockService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * sku的库存 前端控制器
 * </p>
 *
 * @author WJZ
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/sku")
public class PmsSkuStockController {

    @Autowired
    private PmsSkuStockService pmsSkuStockService;

    @PostMapping("/update/{pid}")
    public R<String> updateSkuStock(@PathVariable("pid") Long pid, @RequestBody List<PmsSkuStock> skuStockList){
        pmsSkuStockService.updateSkuStock(pid,skuStockList);
        return R.success("");
    }

    //根据商品ID及sku编码模糊搜索sku库存
    @GetMapping("/{pid}")
    public R sku(@PathVariable("pid") Integer pid, String keyword){

        List<PmsSkuStock> pmsSkuStock = pmsSkuStockService.findByid(pid,keyword);
        return R.success(pmsSkuStock);
    }
}
